home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / plotting / imagetoo / imagetl1.lha / Imagetool / HDF / dfconvert.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-09-20  |  3.6 KB  |  124 lines

  1. /*****************************************************************************
  2. *              NCSA HDF version 3.10
  3. *                July 1, 1990
  4. *
  5. * NCSA HDF Version 3.10 source code and documentation are in the public
  6. * domain.  Specifically, we give to the public domain all rights for future
  7. * licensing of the source code, all resale rights, and all publishing rights.
  8. * We ask, but do not require, that the following message be included in all
  9. * derived works:
  10. * Portions developed at the National Center for Supercomputing Applications at
  11. * the University of Illinois at Urbana-Champaign.
  12. * THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
  13. * SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
  14. * WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
  15. *****************************************************************************/
  16.  
  17. /*
  18. $Header: /pita/work/HDF/dev/RCS/src/dfconvert.h,v 3.3 90/07/02 09:40:04 clow beta $
  19.  
  20. $Log:    dfconvert.h,v $
  21.  * Revision 3.3  90/07/02  09:40:04  clow
  22.  * enclosed DFconvert macro and function with an #ifdef on FUNC_CONV
  23.  * so that the selection between these is a compilation option
  24.  * 
  25.  * Revision 3.2  90/06/21  10:39:13  clow
  26.  * Expanded DFconvert macro so that it is as complete as the function
  27.  * 
  28.  * Revision 3.1  90/05/21  08:59:15  clow
  29.  * if it's unicos, use the fortran optimized convertsion routines
  30.  * added macros to do above
  31.  * 
  32.  * Revision 3.0  90/02/19  15:22:17  pwebb
  33.  * Macro to replace function call
  34.  * 
  35. */
  36. /* In order to speed the conversion process, eliminate a layer of function
  37.  * calls by making DFconvert into a macro.
  38.  * Peter Webb, Oct 11, 1989
  39.  */
  40. #ifndef DFCONVERT_H
  41. #define DFCONVERT_H
  42. #ifndef FUNC_CONV
  43. /* This is the default */
  44. /* using the DFconvert macro instead of function */
  45. #define DFconvert(src,dest,ntype,stype,dtype,size,status)\
  46. { char *s=(src), *d=(dest);\
  47.   int nt=(ntype), st=(stype), dt=(dtype);\
  48.   int sz=(size);\
  49.   if (nt==DFNT_FLOAT) {\
  50.     if ((st==DFNTF_IEEE && dt==DFNTF_PC) ||\
  51.         (st==DFNTF_PC && dt==DFNTF_IEEE)) {\
  52.       register int i;\
  53.       for (i=0;i<sz*4;i+=4) {\
  54.         d[i] = s[i+3];\
  55.         d[i+1] = s[i+2];\
  56.         d[i+2] = s[i+1];\
  57.         d[i+3] = s[i];\
  58.       }\
  59.       status=0;\
  60.     } else {\
  61.       if (st==DFNTF_PC) {\
  62.         register int i;\
  63.         register char t;\
  64.         for (i=0;i<sz*4;i+=4) {\
  65.           t = s[i];\
  66.           s[i] = s[i+3];\
  67.           s[i+3] = t;\
  68.           t = s[i+1];\
  69.           s[i+1] = s[i+2];\
  70.           s[i+2] = t;\
  71.         }\
  72.         st=DFNTF_IEEE;\
  73.       }\
  74.       if (st==DFNTF_IEEE && dt==DFNTF_CRAY) {\
  75.         SCUP32(s,d,&sz,&(status));\
  76.       } else if (st==DFNTF_CRAY && (dt==DFNTF_IEEE || dt==DFNTF_PC)) {\
  77.         CSPK32(s,d,&sz,&(status));\
  78.       } else if (st==DFNTF_IEEE && dt==DFNTF_VAX) {\
  79.         status = DFCVieeeF2vaxF(s,d,sz);\
  80.       } else if (st==DFNTF_VAX && (dt==DFNTF_IEEE || dt==DFNTF_PC)) {\
  81.         status = DFCVvaxF2ieeeF(s,d,sz);\
  82.       } else {\
  83.         status = -1;\
  84.       }\
  85.       if (dt==DFNTF_PC) {\
  86.         register int i;\
  87.         register char t;\
  88.         for (i=0;i<sz*4;i+=4) {\
  89.           t = d[i];\
  90.           d[i] = d[i+3];\
  91.           d[i+3] = t;\
  92.           t = d[i+1];\
  93.           d[i+1] = d[i+2];\
  94.           d[i+2] = t;\
  95.         }\
  96.       }\
  97.       if ((stype)==DFNTF_PC) {\
  98.         register int i;\
  99.         register char t;\
  100.         for (i=0;i<sz*4;i+=4) {\
  101.           t = s[i];\
  102.           s[i] = s[i+3];\
  103.           s[i+3] = t;\
  104.           t = s[i+1];\
  105.           s[i+1] = s[i+2];\
  106.           s[i+2] = t;\
  107.         }\
  108.         st=DFNTF_IEEE;\
  109.       }\
  110.     }\
  111.   } else {\
  112.   status = -1;\
  113.   }\
  114.   if (status == -1) DFerror = DFE_BADCONV;\
  115. }
  116. #endif /* !FUNC_CONV */
  117.  
  118. #endif /* !DFCONVERT_H */
  119.